import assert from 'node:assert/strict';
import test from 'node:test';
import { main } from '../../src/index.js';
import baseCounters from '../helpers/baseCounters.js';
import { createOptions } from '../helpers/create-options.js';
import { resolve } from '../helpers/resolve.js';

const cwd = resolve('fixtures/plugins/xo');

test('Find dependencies with the xo plugin', async () => {
  const options = await createOptions({ cwd });
  const { issues, counters } = await main(options);

  assert(issues.unresolved['.xo-config.js']['eslint-plugin-unused-imports']);
  assert(issues.unlisted['xo.config.cjs']['glob']);
  assert(issues.unresolved['package.json']['eslint-plugin-eslint-comments']);

  assert.deepEqual(counters, {
    ...baseCounters,
    processed: 2,
    unlisted: 1,
    unresolved: 2,
    total: 2,
  });
});
